﻿using System;
using System.Collections.Generic;

namespace Sripirom.ATS.Core.ExceptionHandler
{
    public class MessageException : ExceptionGeneric
    {
        #region Attributes
        public string TransactionID { get; set; }
        protected Dictionary<int, string> _DictParameter;
        public Dictionary<int, string> DictParameter
        {
            get
            {
                return this._DictParameter;
            }
            set
            {
                this._DictParameter = value;
            }
        }
        #endregion

        #region Constructor
        public MessageException() : base()
        {
        }

        public MessageException(string code) : base(code)
        {            
            this.Code = code;
        }

        public MessageException(string code, Exception e) : base(code, e)
        {
            this.Code = code;
        }

        public MessageException(string code, Dictionary<int, string> dictParam) : this(code)        
        {
            this._DictParameter = dictParam;
        }

        public MessageException(string code, string[] msgParams) : this(code)
        {
            if(msgParams != null)
            {
                Dictionary<int, string> dictParam = new Dictionary<int, string>();
                int i = 0;
                foreach (string param in msgParams)
                {
                    dictParam.Add(i++, param);
                }
                this._DictParameter = dictParam;
            }
        }

        public MessageException(string code, string[] msgParams, Exception e) : this(code, e)
        {
            if (msgParams != null)
            {
                Dictionary<int, string> dictParam = new Dictionary<int, string>();
                int i = 0;
                foreach (string param in msgParams)
                {
                    dictParam.Add(i++, param);
                }
                this._DictParameter = dictParam;
            }
        }
        
        public MessageException(string code, String transactionID) : this(code)
        {
            this.TransactionID = transactionID;
        }

        #endregion Constructor
    }
}
